package com.sky.task;

import com.alibaba.fastjson.JSON;
import com.sky.entity.Dish;
import com.sky.mapper.DishMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//@Component
@Slf4j
public class MyTask {

    @Autowired
    DishMapper dishMapper;

    // @Scheduled(fixedRate = 1000) // 定点时间执行
    @Scheduled(cron = "0/2 * * * * ?" ) // 特定频率执行
    public void timingTask() {
        Dish dish = dishMapper.getById(50L);
        log.info("定时任务开始执行: {}" ,JSON.toJSONString(dish));
    }
}
